package suzf.top.kotlinjava.common.utils

import org.springframework.security.core.context.SecurityContextHolder
import suzf.top.kotlinjava.common.security.DisableDefaultUserDetails

/**
 *  安全用户工具类
 *========================
 * Created with IntelliJ IDEA
 * Author:Mr.Su
 * Date:2019/9/28
 * Time:14:06
 * ========================
 */
class SecurityUserTools {
    companion object {
        fun getCurrentUser(): String? {
            val principal = SecurityContextHolder.getContext().authentication.principal
                    as DisableDefaultUserDetails
            return principal.username
        }
    }
}
